package cn.tedu.serialscore;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SerialScoreReducer extends Reducer<Text, Score, Text, IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<Score> values, Context context) throws IOException, InterruptedException {
        int max = 0;
        for (Score val : values) {
            for (int score : val.getScores()) {
                if (max < score) max = score;
            }
        }
        context.write(key, new IntWritable(max));
    }
}
